home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13695 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  74 lines

  1. Path: csun.edu!kc44097
  2. From: kc44097@csun.edu (chen)
  3. Newsgroups: comp.lang.c
  4. Subject: Beginner need help??????????????
  5. Date: 9 Apr 1996 21:53:06 GMT
  6. Organization: California State University, Northridge
  7. Message-ID: <4kem82$5j3@dewey.csun.edu>
  8. NNTP-Posting-Host: louie.csun.edu
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11.  
  12.        I am a new comer of C language and I use Boland C++ 3.1 as
  13. my compiler.These days I found some wierd things happens.I do not
  14. know is cause by my compiler or is the restriction of the language
  15. itself.Can anyone give me some advice.Please e-mail me
  16.  
  17.                My e-mail is kc44097@huey.csun.edu
  18.  
  19.                         Thankx !
  20.  
  21.  
  22.  
  23. -------- program 1 -------------------------
  24. #include <stdio.h>
  25.  
  26. float answer;  
  27.  
  28. main ()
  29. {
  30.   answer = 1 / 3;
  31.   printf("The value of 1/3 is %f\n",
  32.                  answer);
  33.  
  34.   return(0);
  35. }
  36.  
  37.  
  38. ????? The answer should be 0.333333 but compiler give me 0.000000 ??????
  39.  
  40. ----------program 2----------------------------
  41. #include <stdio.h>
  42.  
  43. float result;
  44.    
  45.  
  46. main()
  47. {
  48.   result = 7.0 / 22.0;
  49.  
  50.   printf("The result is %d\n", result);
  51.   return (0);
  52. }
  53.  
  54. ???? The answer should be 0.31818 but compiler give me 0 ????
  55.  
  56. ----------program 3---------------------------
  57. #include <stdio.h>
  58.  
  59. int   integer;
  60. float floating;
  61.    
  62.  
  63. main()
  64. {
  65.   floating = 7.0 / 22.0;
  66.   
  67.   integer = floating;
  68.  
  69.   printf("The value of integer is %f\n", integer);
  70.   return (0);
  71. }
  72.  
  73. ???? The answer should be 0.31818 but compiler give me 0.000000 ?????
  74.